package com.sofly.service.impl.group3;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sofly.dao.group3.IInStockInfoDao;
import com.sofly.dao.group3.IStockManageDao;
import com.sofly.entity.InStockInfo;
import com.sofly.entity.StockManage;
import com.sofly.service.group3.IInStockInfoService;
/**
 * 
* <p>Title:IInStockInfoServiceImpl </p>
* <p>Description: </p>
* <p>Company: </p> 
* @author ChengShiMin
* @date 下午4:12:56
 */
@Service
public class IInStockInfoServiceImpl implements IInStockInfoService {

	
	@Autowired
	private IInStockInfoDao inStockInfoDao;
	@Autowired
	private IStockManageDao stockManageDao;
	@Override
	public List<InStockInfo> getInStockInfoList(int page, int size) {
		// TODO Auto-generated method stub
		return inStockInfoDao.selectInStockInfoList(page, size);
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return inStockInfoDao.selectCount();
	}
	@Override
	public int addInStockInfo(InStockInfo inStockInfo) {
		// TODO Auto-generated method stub
		String productId = inStockInfo.getMaterielModel();
		int number = inStockInfo.getMaterielAmount();
		StockManage stockManage = stockManageDao.selectStockById(productId);
		int number1 = stockManage.getAmount();
		stockManage.setAmount(number+number1);
		stockManageDao.updateStockManage(stockManage);
		return inStockInfoDao.insertInStockInfo(inStockInfo);
	}
	@Override
	public InStockInfo getInStockInfo(String materielName) {
		// TODO Auto-generated method stub
		return inStockInfoDao.selectInStockInfo(materielName);
	}
	@Override
	public int getCount1(String inStockDate) {
		// TODO Auto-generated method stub
		return inStockInfoDao.selectCount1(inStockDate);
	}
	@Override
	public List<InStockInfo> getInStockInfoListBydate(String inStockDate, int page, int size) {
		// TODO Auto-generated method stub
		return inStockInfoDao.selectInStockInfoListBydate(inStockDate, page, size);
	}

}
